package com.change.study.data.app;

import java.lang.annotation.Annotation;
import java.util.Date;
import java.util.Map;
import java.util.Random;
import java.util.Set;

import com.change.study.data.entity.User;
import com.change.study.data.entity.UserRole;
import com.change.study.data.service.UserService;
import com.openyelp.annotation.RestFul;

public class UserServiceAppsr {
	// http://192.168.0.188:8080/study/
	// http://ad.xabaoyi.com:8080/study/
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		UserService userService = RpcUtils.get(UserService.class);
		x(userService);
		// x(userService);
		// Pagination<User> p= userService.findByRole(2l, 1, 10);
		// List<User> us=p.getList();
		// for (User user : us) {
		// System.out.println(user);
		// }
		//
		// Pagination<User> user=new Pagination<User>();
		// user.setList(new ArrayList<User>());
		// System.out.println(user.getList().getClass());
	}

	private static void x(UserService userService) {
		User m = new User();
		m.setUsername("admin");
		m.setEmail("f");
		m.setAddDate(new Date());
		m.setLastDate(new Date());
		m.setIntroduction("我是一个好人");
		m.setPassword("123456");
		m.setPlainPassword("123456");
		m.setName("ada" + new Random().nextInt(Integer.MAX_VALUE));
		m = userService.save(m);

		// //m=userService.findById(1l);
		// System.out.println(m.getRoles());
		// UserRole bean=new UserRole("admin");
		// bean.setDescription("adminer");
		// bean.setId(1l);
		// // roleService.save(bean);
		// userService.addRole(m.getId(), bean);
	}

	private static void xx() {
		Map<String, Object> os = ObjectFactory.get().getBeansWithAnnotation(
				RestFul.class);

		Set<String> sets = os.keySet();

		for (String key : sets) {
			Object o = os.get(key);
			Class[] classs = o.getClass().getInterfaces();
			for (Class class1 : classs) {
				Annotation xx = class1.getAnnotation(RestFul.class);
				if (xx instanceof RestFul) {
					RestFul xxx = (RestFul) xx;
					String apiname = xxx.value();
				}

			}

		}
	}

}
